#include <ctime>
#include <iostream>

using std::cout;
using std::endl;

void test0()
{
    int iNumber = 100;
    float fNumber = 12.34;
    iNumber = (int)fNumber;//C风格的,ok
    iNumber = int(fNumber);//C风格的,ok
                           
    cout << "iNumber = " << iNumber << endl;
    cout << "fNumber = " << fNumber << endl;
}

void test()
{
    int iNumber = 100;
    float fNumber = 333.456;
    //1、可以在普通数据类型之间进行转换
    iNumber = static_cast<int>(fNumber);//C++风格的强转
                           
    cout << "iNumber = " << iNumber << endl;
    cout << "fNumber = " << fNumber << endl;

    //2、void *指针与普通指针之间的转换
    int *pInt = static_cast<int *>(malloc(sizeof(int)));

    int value = 100;
    int *pInt2 = &value;
    /* float *pF = static_cast<float *>(pInt);//error */
    float *pF = reinterpret_cast<float *>(pInt);//ok
}
int main(int argc, char *argv[])
{
    test();
    return 0;
}

